package com.zxt.content.job.scheduled;

import com.zxt.content.thirdParty.resp.JobSendEmailVO;
import com.zxt.content.thirdParty.service.JobSendEmailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;


@Slf4j
@EnableScheduling
@Component
@EnableAsync
@AllArgsConstructor
public class JobSendEmailSchedule {

    private final JobSendEmailService jobSendEmailService;

    /**
     * 时间邮件
     *
     * @Async+@Scheduled 定时任务不阻塞功能，让定时任务开异步线程执行
     */
    @Async
    @Scheduled(cron = "0 0 0 * * ?")
    public void dealJobSendEmail() {
        log.info("定时处理时间邮件start..........");
        List<JobSendEmailVO> list = jobSendEmailService.getUnDealList();
        jobSendEmailService.dealSend(list);
        log.info("定时处理时间邮件end..........");
    }
}
